package com.fqy.thread02.procon01;

/**
 * User: fqy
 * Date: 2021/9/1
 * Time: 13:34
 * Describe: 模拟空调类
 */
public class AirCondition {

    private Integer num = 0;

    public synchronized void increament() throws InterruptedException {
        while (num != 0){
            wait();
        }
        System.out.println(Thread.currentThread().getName()+"\t"+(++num));

        notifyAll();
    }

    public synchronized void decreament() throws InterruptedException {
        while (num != 1){
            wait();
        }
        System.out.println(Thread.currentThread().getName()+"\t"+(--num));
        notifyAll();
    }
}
